﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The Grouped Items Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234231

namespace WRS
{
    /// <summary>
    /// A page that displays a grouped collection of items.
    /// </summary>
    public sealed partial class Page2 : WRS.Common.LayoutAwarePage
    {
        public Page2()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property provides the grouped collection of items to be displayed.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.DefaultViewModel["Groups"] = e.Parameter;
            //itemGridView.Items.Add(new object());
            //MessageDialog d = new MessageDialog(itemGridView.Items.Count.ToString());
            //await d.ShowAsync();

             
        }
           
        

        private void itemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
// Determine what group the Button instance represents
            var group = (sender as GridView).SelectedItem;

            // Navigate to the appropriate destination page, configuring the new page
            // by passing required information as a navigation parameter
          
            this.Frame.Navigate(typeof(Page3), group);
        }

        private void Background_Loaded(object sender, RoutedEventArgs e)
        {
            if (DateTime.Now.Hour >= 6 && DateTime.Now.Hour < 12)
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Morning.png", UriKind.Absolute));
                Background.Background = bg;
            }
            else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 18)
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Noon.png", UriKind.Absolute));
                Background.Background = bg;
            }
            else
            {
                ImageBrush bg = new ImageBrush();
                bg.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/Night.png", UriKind.Absolute));
                Background.Background = bg;
            }
        }

    }
}
